# -*- mode: python -*-
# vi: set ft=python :

# Copyright 2020 Massachusetts Institute of Technology.
# Licensed under the BSD 3-Clause License. See LICENSE.TXT for details.

workspace(name = "underactuated")

load(
    "//htmlbook/tools:repositories.bzl",
    "rt_dependencies",
    "rt_toolchains",
)

rt_dependencies()

rt_toolchains()

load("@bazel_skylib//lib:versions.bzl", "versions")

versions.check("2.0.0")

load(
    "//htmlbook/tools/python:repositories.bzl",
    "rt_pip3_import",
    "rt_python_repositories",
)

rt_python_repositories()

rt_pip3_import(name = "pip")

load("@pip//:requirements.bzl", "pip_install")

pip_install()

load("//htmlbook/tools/buildifier:repositories.bzl", "buildifier_dependencies")

buildifier_dependencies()

load("//htmlbook/tools/tidy:repositories.bzl", "tidy_dependencies")

tidy_dependencies()

# Set the DRAKE_INSTALL_DIR environment variable to the correct path; if
# DRAKE_INSTALL_DIR is not set it will look in "/opt/drake".
load("//htmlbook/tools:environ.bzl", "environ_repository")

# Allowing PWD to be loaded here is a terrible work-around that allows me to
# pass the equivalent of BUILD_WORKSPACE_DIRECTORY as a command line argument
# (since it's not available to tests).  This enables *non-hermetic* tests...
# which I introduced because it is hard to list all .py and .ipynb  files as
# dependencies via bazel's glob since "labels are not allowed to cross the
# package boundary and glob does not match files in subpackages."
environ_repository(
    name = "environ",
    vars = [
        "DRAKE_INSTALL_DIR",
        "PWD",
    ],
)

load("@environ//:environ.bzl", "DRAKE_INSTALL_DIR")

new_local_repository(
    name = "rules_drake",
    build_file_content = "",
    path = DRAKE_INSTALL_DIR if DRAKE_INSTALL_DIR else "/opt/drake",
)

load("@rules_drake//:share/drake/repo.bzl", "drake_repository")

drake_repository(name = "drake")
